//
// Created by 董一龙 on 2022/10/13.
//

#ifndef FQUEUE_QUEUE_OPERATOR_INTERFACE_H
#define FQUEUE_QUEUE_OPERATOR_INTERFACE_H

#include <sys/types.h>

namespace fqueue {
    template <typename ImplOpType>
    class queue_operator_interface {
    private:
        static bool has_format(void *buffer, size_t buffer_size) {
            return ImplOpType::has_format(buffer, buffer_size);
        }
    public:
        static int format(void *buffer, size_t buffer_size) {
            if (has_format(buffer, buffer_size)) {
                return 0;
            }
            return ImplOpType::format(buffer, buffer_size);
        }
        static size_t capacity(void *buffer, size_t buffer_size) {
            return ImplOpType::capacity(buffer, buffer_size);
        }
        static size_t size(void *buffer, size_t buffer_size) {
            return ImplOpType::size(buffer, buffer_size);
        }
        static int enqueue(void *buffer, size_t buffer_size, void const*input, size_t input_length) {
            return ImplOpType::enqueue(buffer, buffer_size, input, input_length);
        }
        static int dequeue(void *buffer, size_t buffer_size, void *output, size_t output_length) {
            return ImplOpType::dequeue(buffer, buffer_size, output, output_length);
        }
        static int clear(void *buffer, size_t buffer_size) {
            return ImplOpType::clear(buffer, buffer_size);
        }

    };

} // fqueue

#endif //FQUEUE_QUEUE_OPERATOR_INTERFACE_H
